1、树的子结构
思想：就是递归，先看根节点，再看左子树，右子树
/*
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
			val(x), left(NULL), right(NULL) {
	}
};*/
class Solution {
public:
    bool _HasSubtree(TreeNode* pRoot1, TreeNode* pRoot2)
    {
        //如果子树遍历完了，说明肯定是父树的子树
        if(pRoot2==nullptr)
            return true;
        //如果父树遍历完了，说明子树不是
        if(pRoot1==nullptr)
            return false;
        if(pRoot1->val!=pRoot2->val)
            return false;
        return _HasSubtree(pRoot1->left,pRoot2->left)&&_HasSubtree(pRoot1->right,pRoot2->right);
    }
    bool HasSubtree(TreeNode* pRoot1, TreeNode* pRoot2) {
        if(pRoot1==nullptr||pRoot2==nullptr)
            return false;
        //子树可能在根节点位置，也可能在左子树，也可能在右子树
        return _HasSubtree(pRoot1,pRoot2)||HasSubtree(pRoot1->left,pRoot2)||HasSubtree(pRoot1->right,pRoot2);
    }
};

2、二叉搜索树的后序遍历
思想：就是将数组拆分，因为后序遍历，最后一个元素一定是根，然后咋根据二叉搜索树的特点。左子树小于根，右子树大于根
class Solution {
public:
    
    bool _VerifySquenceOfBST(vector<int> sequence,int l,int r)
    {
        if(l>=r-1)
            return true;
        int ans=sequence[r];
        int i=l;
        while(i<r)
        {
            if(sequence[i]>ans)
                break;
            i++;
        }
        int m=i-1;
        int x1=l;
        int x2=r-1;
        while(x1<=m)
        {
            if(sequence[x1]>ans)
                return false;
            x1++;
        }
        while(i<=x2)
        {
            if(sequence[i]<ans)
                return false;
            i++;
        }
        return _VerifySquenceOfBST(sequence,l,m)&&_VerifySquenceOfBST(sequence,m+1,x2);
    }
    bool VerifySquenceOfBST(vector<int> sequence) {
        if(sequence.empty())
            return false;
        return _VerifySquenceOfBST(sequence,0,sequence.size()-1);
    }
};

3、二叉树中和为某一值得路径
思想：深度优先搜索+回朔，退出条件，
/*
struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
	TreeNode(int x) :
			val(x), left(NULL), right(NULL) {
	}
};*/
class Solution {
public:
    void dfs(TreeNode* root,int expectNumber,vector<vector<int>>& vv,vector<int>& v)
    {
        v.push_back(root->val);
        if(expectNumber==root->val&&!root->left&&!root->right)
        {
            vv.push_back(v);
        }
        if(root->left)
            dfs(root->left,expectNumber-root->val,vv,v);
        if(root->right)
            dfs(root->right,expectNumber-root->val,vv,v);
        v.pop_back();
    }
    vector<vector<int> > FindPath(TreeNode* root,int expectNumber) {
        
        vector<vector<int>> vv;
        if(root==nullptr)
            return vv;
        vector<int> v;
        dfs(root,expectNumber,vv,v);
        return vv;
    }
};